#include <iostream>
#include <cstring>

using namespace std;
// #define ONLINE_JUDGE
const int N = 3e5 + 10;

int n, m; 
int w[N];
int q[N], f[N]; // 滑动窗口队列

bool check(int limit)
{
    int hh = 0, tt = 0;
    for(int i = 1; i <= n; i++)
    {
        if(q[hh] < i - limit - 1) hh++;
        f[i] = f[q[hh]] + w[i];
        while(hh <= tt && f[q[tt]] >= f[i]) tt--;
        q[++tt] = i; 
    }

    for(int i = n - limit; i <= n; i++)
        if(f[i] <= m)
            return true;
    return false;
}

int main() {

    #ifdef ONLINE_JUDGE

    #else
    freopen("./in.txt","r",stdin);
    #endif
    ios::sync_with_stdio(false);   
	cin.tie(0);

    cin >> n >> m;
    for(int i = 1; i <= n; i++) cin >> w[i];

    int l = 0, r = n;
    while(l < r)
    {
        int mid = l + r >> 1;
        if(check(mid)) r = mid;
        else l = mid + 1;
    }

    cout << r << endl;
    return 0;
}
